package com.example.my.fragment;

import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.viewpager.widget.PagerAdapter;

import java.util.ArrayList;
import java.util.List;

public class ImgAdapter extends PagerAdapter {
    private List<View>mList = new ArrayList<>();
    public ImgAdapter(List<View>list){
        mList=list;
    }
    @Override
    public int getCount() {
        return mList == null ? 0:mList.size();
    }

    @Override
    public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
        return view==object;
    }
    @NonNull
    @Override
    public Object instantiateItem(@NonNull ViewGroup container,int position){
        container.addView(mList.get(position));
        return mList.get(position);
    }
    @Override
    public void destroyItem(@NonNull ViewGroup container,int position,@NonNull Object object){
        container.removeView(mList.get(position));

    }
}
